import { http } from "@/utils/http";

/** 告警通知消息模型定义 */
export type AlertPeopleMsgModel = {
  id: number;
  alertLogId: number;
  peopleId: number;
  noticeType: string;
  status: number;
  statusMsg: string;
  content: string;
  createdAt: string;
  updatedAt: string;
};

/** 分页获取告警通知消息列表 */
export const getAlertPeopleMsgListApi = (data: IReqPagerData) => {
  return http.request<Resp<IRespPagerData<AlertPeopleMsgModel>>>(
    "get",
    "/alert-people-msg/page-list",
    { params: data }
  );
};

/** 新增告警通知消息 */
export const addAlertPeopleMsgApi = (data: Partial<AlertPeopleMsgModel>) => {
  return http.request<Resp<null>>("post", "/alert-people-msg", { data });
};

/** 更新告警通知消息 */
export const updateAlertPeopleMsgApi = (id: number, data: Partial<AlertPeopleMsgModel>) => {
  return http.request<Resp<null>>("put", `/alert-people-msg/${id}`, { data });
};

/** 更新告警通知消息状态 */
export const updateAlertPeopleMsgStatusApi = (id: number, status: number, statusMsg?: string) => {
  return http.request<Resp<null>>("patch", `/alert-people-msg/${id}/status`, {
    data: { status, statusMsg }
  });
};

/** 删除告警通知消息 */
export const deleteAlertPeopleMsgApi = (id: number) => {
  return http.request<Resp<null>>("delete", `/alert-people-msg/${id}`);
};

/** 批量删除告警通知消息 */
export const batchDeleteAlertPeopleMsgApi = (ids: number[]) => {
  return http.request<Resp<null>>("delete", "/alert-people-msg/batch-del", {
    data: { ids }
  });
};

/** 根据ID获取告警通知消息详情 */
export const getAlertPeopleMsgByIdApi = (id: number) => {
  return http.request<Resp<{
    info: AlertPeopleMsgModel
  }>>('get', '/alert-people-msg/getOne', {
    params: { id }
  });
};

/** 获取告警通知消息选项列表 */
export const getAlertPeopleMsgOptionsApi = (params?: { fieldKey?: string; fieldLabel?: string }) => {
  return http.request<Resp<{
    options: Array<{
      label: string;
      val: string | number;
    }>
  }>>('get', '/alert-people-msg/getOptions', { params });
};